//
//  Place.m
//  YouthOlympic2014
//
//  Created by Li Yuhang on 14-7-1.
//  Copyright (c) 2014年 mitian. All rights reserved.
//

#import "Place.h"

@implementation Place
@synthesize id,latitude,longtitude,address,name,imageName,picTag,hasSubLocation;

+(NSArray*/*Place*/) instanceList:(NSDictionary*) jsonData{
    NSArray *jsonPlaces = (NSArray*)jsonData[@"location"];
    NSMutableArray* /*Place*/ places = [[NSMutableArray alloc]init];
    //
    for(int i=0; i< jsonPlaces.count ; i++){
        Place* place = [[Place alloc]init];
        NSDictionary* placeJson = jsonPlaces[i];
        place.id = placeJson[@"placeid"];
        place.name = placeJson[@"name"];
        place.address = placeJson[@"address"];
        place.picTag = placeJson[@"pic"];
        place.latitude = placeJson[@"lat"];
        place.longtitude = placeJson[@"lon"];
        place.hasSubLocation = [@"true" isEqualToString:placeJson[@"hasSubLocation"]] ? true: false;
        [places addObject:place];
    }

    return [NSArray arrayWithArray:places];
}

- (UIImage*)icon{
    return [AppUtils getPlaceIcon:self.picTag];
}

-(NSString *)description{
    return [NSString stringWithFormat: @"{id:%@, name:%@, address:%@, picTag:%@, latitude:%@, longtitude:%@}", self.id, self.name, self.address, self.picTag, self.latitude, self.longtitude];
}


@end
